package com.shoeshopping.dao.pc;

import java.sql.SQLException;
import java.util.List;

import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.shoeshopping.dao.BaseDaoImpl;
import com.shoeshopping.entity.GoodsItem;
import com.shoeshopping.utils.pc.HibernateUtils;

@Repository("getIntoCartDao")
public class GetIntoCartDaoImpl extends BaseDaoImpl implements GetIntoCartDao {

	Session session = HibernateUtils.getSession();
/*
	public void UPDATE(Object entity) {
		session.beginTransaction();
		session.update(entity);
		session.getTransaction().commit();
	}
	
	*/
	//My own mehtod by pc
	@Override
	public void deleteByCartId(String cartId) {
		
		String hql = "update ShoppingCart sc set sc.goosItems = null where sc.id = ?";
		
		Query query = session.createQuery(hql);
		query.setString(1, cartId);
		query.executeUpdate();
		session.getTransaction().commit();
	}
	
	
}
